package com.personal.system.domain;

import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ApprovalProcessConstants {

    public enum ApprovalModuleEnum{

        APPROVAL_MODULE_01("01", "气销报价", 4,RuleClassEnum.getByType("01")),
        APPROVAL_MODULE_02("02", "气采报价", 3,RuleClassEnum.getByType("02")),
        APPROVAL_MODULE_03("03", "运力报价", 1,RuleClassEnum.getByType("03")),
        APPROVAL_MODULE_04("04", "结算管理", 2,RuleClassEnum.getByType("04")),
        APPROVAL_MODULE_05("05", "调度管理", 5,RuleClassEnum.getByType("05")),
        APPROVAL_MODULE_06("06", "发票管理", 6,RuleClassEnum.getByType("06"));

        private String code;
        private String name;
        private int sort;
        private List<RuleClassEnum> rules;

        ApprovalModuleEnum(String code, String name, int sort, List<RuleClassEnum> rules) {
            this.code = code;
            this.name = name;
            this.sort = sort;
            this.rules = rules;
        }

        public String getName() {
            return name;
        }

        public String getCode() {
            return code;
        }

        public int getSort() {
            return sort;
        }

        public void setSort(int sort) {
            this.sort = sort;
        }

        public List<RuleClassEnum> getRules() {
            return rules;
        }

        public void setRules(List<RuleClassEnum> rules) {
            this.rules = rules;
        }

        public static ApprovalModuleEnum getByCode(String code) {
            for (ApprovalModuleEnum isUnload : ApprovalModuleEnum.values()) {
                if (isUnload.getCode().equals(code)) {
                    return isUnload;
                }
            }
            return null;
        }

    }

    public enum RuleClassEnum {

        RULE_CLASS_01("01", "压车审批", "03", 13), RULE_CLASS_02("02", "调整单管理", "04", 5),
        RULE_CLASS_03("03", "气销报价", "01", 11), RULE_CLASS_04("04", "气销指数", "01", 10),
        RULE_CLASS_05("05", "原有气销指数", "01", 12), RULE_CLASS_06("06", "气销合同", "01", 9),
        RULE_CLASS_07("07", "气采报价", "02", 8), RULE_CLASS_08("08", "气采合同", "02", 7),
        RULE_CLASS_09("09", "运采报价", "03", 1), RULE_CLASS_10("10", "运销报价", "03", 2),
        RULE_CLASS_11("11", "运采合同", "03", 3), RULE_CLASS_12("12", "运销合同", "03", 4),
        RULE_CLASS_13("13", "冲销审批", "04", 6), RULE_CLASS_14("14", "指数规则", "01", 14),
        RULE_CLASS_15("15", "优惠规则", "01", 15), RULE_CLASS_18("18", "气采市场指导价", "02", 3),
        RULE_CLASS_16("16", "异常应收账单审批", "04", 7), RULE_CLASS_17("17", "异常应付账单审批", "04", 8),
        RULE_CLASS_19("19", "气差确认单审批", "04", 8),RULE_CLASS_20("20", "成本规则申请", "01", 16);

        private String code;
        private String name;
        private String type;
        private int sort;

        RuleClassEnum(String code, String name, String type, int sort) {
            this.code = code;
            this.name = name;
            this.type = type;
            this.sort = sort;
        }

        public int getSort() {
            return sort;
        }

        public void setSort(int sort) {
            this.sort = sort;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public String getCode() {
            return code;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public static List<RuleClassEnum> getByType(String type) {
            List<RuleClassEnum> rules = Lists.newArrayList();
            for (RuleClassEnum isUnload : values()) {
                if (isUnload.getType().equals(type)) {
                    rules.add( isUnload );
                }
            }
            return rules;
        }

        public static RuleClassEnum getByCode(String code) {
            for (RuleClassEnum isUnload : values()) {
                if (isUnload.getCode().equals(code)) {
                    return isUnload;
                }
            }
            return null;
        }

        public static List<Map<String, String>> getRuleClassMaps() {
            List<Map<String, String>> ruleClassList = new ArrayList<>();
            for (RuleClassEnum item : RuleClassEnum.values()) {
                Map<String, String> map = new HashMap<>();
                map.put("code", item.getCode());
                map.put("name", item.getName());
                map.put("type", item.getType());
                ruleClassList.add(map);
            }
            return ruleClassList;
        }
    }

    public enum AuditTypeEnum{
        AUDIT_TYPE_00("00", "运力确认", "01"), AUDIT_TYPE_01("01", "销售确认", "01"),
        AUDIT_TYPE_03("03", "气销调整单", "02"), AUDIT_TYPE_04("04", "排程调整单", "02"),
        AUDIT_TYPE_05("05", "销售确认", "01"), AUDIT_TYPE_06("06", "高于推荐报价", "03"),
        AUDIT_TYPE_07("07", "低于等于推荐报价", "03"), AUDIT_TYPE_02("02", "否运贸一体", "07"), 
        AUDIT_TYPE_08("08", "是运贸一体", "07"),
        AUDIT_TYPE_09("09", "常规毛利*80%<=测算毛利<常规毛利*200%", "03"),
        AUDIT_TYPE_10("10", "常规毛利*0%<=测算毛利<常规毛利*80% 或 常规毛利*200%<=测算毛利", "03"),
        AUDIT_TYPE_11("11", "测算毛利<0", "03"),
        AUDIT_TYPE_12("12", "(承运|客户)承担>=气差量,(客户|供应商)及公司不承担", "19"),
        AUDIT_TYPE_13("13", "(客户|供应)承担>=气差量,(承运商|客户)及公司不承担", "19"),
        AUDIT_TYPE_14("14", "客户及(承运商|供应商)均承担,公司不承担", "19"),
        AUDIT_TYPE_15("15", "客户及(承运商|供应商)均不承担,公司承担", "19"),
        AUDIT_TYPE_16("16", "(承运商|客户)承担< 气差量,(客户|供应商)不承担,公司承担", "19"),
        AUDIT_TYPE_17("17", "(客户|供应商)承担< 气差量,(承运商|客户)不承担,公司承担", "19"),
        AUDIT_TYPE_18("18", "(承运商|供应商)客户及公司全部承担", "19");

        private String code;
        private String name;
        private String type;

        public String getCode() {
            return code;
        }

        public void setCode(String code) {
            this.code = code;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        AuditTypeEnum(String code, String name, String type) {
            this.code = code;
            this.name = name;
            this.type = type;
        }

        public static List<AuditTypeEnum> getByType(String type) {
            List<AuditTypeEnum> rules = Lists.newArrayList();
            for (AuditTypeEnum isUnload : values()) {
                if (isUnload.getType().equals(type)) {
                    rules.add( isUnload );
                }
            }
            return rules;
        }

    }

}




